package cn.szsys.integration.constants;

/**
 * tianqushuzi学籍核验映射码
 *
 * @author Ryan
 * @since 2025-05-07
 **/
public enum TqszEdcationVerifyMapperedEnum implements UpAndDownCodeBilled {
    /**
     * 上游
     * 200	在籍	计费
     * 10003201	不在籍	计费
     * 10003202	无法确定	不计费
     * 10003203	参数异常	不计费
     * 7001	数据源异常，请稍后重试	不计费
     * <p>
     * <p>
     * 下游
     * 01-在籍
     * 02-不在籍
     * 03-不确定
     * 04-参数异常
     * 05-数据源异常
     */
    IN_SCHOOL("200", "01", true),
    NOT_IN_SCHOOL("10003201", "02", true),
    UNABLE_TO_DETERMINE("10003202", "03", false),
    PARAMETER_ERROR("10003203", "04", false),
    DATA_SOURCE_ERROR("7001", "05", false);
    private final String upstreamCode;
    private final String downstreamCode;
    private final Boolean billing;

    TqszEdcationVerifyMapperedEnum(String upstreamCode, String downstreamCode, Boolean billing) {
        this.upstreamCode = upstreamCode;
        this.downstreamCode = downstreamCode;
        this.billing = billing;
    }

    public static TqszEdcationVerifyMapperedEnum getByUpstreamCode(String upstreamCode) {
        for (TqszEdcationVerifyMapperedEnum resultEnum : TqszEdcationVerifyMapperedEnum.values()) {
            if (resultEnum.upstreamCode.equals(upstreamCode)) {
                return resultEnum;
            }
        }
        return DATA_SOURCE_ERROR;
    }


    /**
     * 上游code
     */
    @Override
    public String getUpstreamCode() {
        return this.upstreamCode;
    }

    /**
     * 下游code
     */
    @Override
    public String getDownstreamCode() {
        return this.downstreamCode;
    }

    /**
     * 是否计费
     */
    @Override
    public Boolean getBilling() {
        return this.billing;
    }
}
